<template>
    <view class="box_1">
        <view class="business-record">
<!--            <view class="r-data">-->
<!--                <view class="top_1_box">-->
<!--                    <view  @tap="hanldeShowData1()"><image class="date_image" src="../../static/img/cash_date.png"></image></view>-->
<!--                    <view class="d-time" @tap="hanldeShowData1()">日期选择</view>-->
<!--                    <view @tap="hanldeShowData1()"><image  class="date_image_2" src="../../static/img/sale_arrow_2.png"/></view>-->
<!--                </view>-->
<!--            </view>-->
            <view class="r-list">
                <view v-if="businessList.length===0">
                    <mNodata></mNodata>
                </view>
                <view  v-else class="l-box" v-for="(item,index) in businessList" :key="index">
                    <view class="b-num">
                        <view class="n-title">现金类型：{{item.type_name}}</view>
                        <view class="n-money"><view class="n-money-text">+{{item.price}}</view></view>
                    </view>
                    <view class="b-time">
                        <view class="t-title">{{item.created_at}}</view>
                    </view>
                </view>
            </view>
        </view>

        <view class="detail_button">
            <view class="get_cash_money">合计可领取：￥{{need_wallet_money}}</view>
            <view>  <button class="detail" @tap="getWallte()">立即领取</button></view>
        </view>


        <Mtips :toShow="tips_show" :message="message"  @sure="sure"></Mtips>
    </view>
</template>

<script>
    import Mtips from '@/components/m-tips.vue'
    export default {
        name: "walletLog",
        data() {
            return {
                businessList:[],
                beginShowData:false,
                endShowData:false,
                start_time:'',
                end_time:'',
                page:1,
                is_load:0,
                select_show:false,
                need_wallet_money:'0.00',
                tips_show:false,
                message:'领取成功,请到现金明细查看！'
            }
        },
        onShow() {
            this.getBuyLog()
        },
        onReachBottom() {  //分页加载请求数据
            if(this.is_load>0){
                this.page++
                this.getBuyLog()
            }else{
                uni.showToast({
                    title:"没有更多数据啦",
                    icon:"none",
                    duration:3000
                })
            }
        },
        methods: {
            //立即领取钱包余额到现金
            async getWallte(){
                if(this.need_wallet_money>0){
                    uni.showLoading({})
                    let resData =await this.$apis.getWalletNow({
                        access_token: '',
                        page:this.page,
                    })
                    if(resData.code===0){
                        this.tips_show=true; //显示确定弹出框
                    }
                    uni.hideLoading()
                }else{
                    uni.showToast({  //异常状态码直接在此处就弹出提示
                        title: '暂无可领取的钱包金额',
                        icon: "none",
                        duration:3000
                    })
                }

            },

            //获取列表
            async getBuyLog(){
                uni.showLoading({})
                let resData =await this.$apis.getWalletLog({
                    access_token: '',
                    page:this.page,
                })
                if(resData.code===0){
                    this.businessList.push(...resData.data.lists)
                    this.is_load=resData.data.is_load
                    this.need_wallet_money=resData.data.need_wallet_money
                }
                uni.hideLoading()
            },
            sure(res){ // 子组件传递过来的东西
                this.tips_show=res;
                uni.redirectTo({
                    url:'/pages/user/myWallet'
                })
            }
        },
        components: {
            Mtips
        },
    }
</script>
<style>
    page {
        padding-bottom: 500rpx !important;
        background-color:#FAFAFA
    }
</style>
<style lang="less" scoped>
    .business-record{
        background-color: #ffffff;
        position: relative;
        width: 100%;
        /*margin-left: 50rpx;*/
        .r-data{
            position: fixed;
            background-color: #ffffff;
            width: 100%;
            height: 80rpx;
            display: flex;
            box-sizing: border-box;
            padding: 0 30rpx;
            justify-content: space-between;
            align-items: center;
            border-bottom: solid 1px #EDEDED;
            .d-time{
                font-size: 22rpx;
                color: #999999;
                margin-left: 10rpx;
                width: 100rpx;
                margin-top: 9rpx;
                line-height: 1.5;


            }
            .date_arrow_image{
                position: relative;
                width: 40rpx;
                height: 40rpx;
                /*margin-left: -120rpx;*/
            }
        }
        .r-list{
            /*margin-bottom: 600rpx;*/
            width: 100%;
            box-sizing: border-box;
            padding: 0rpx 20rpx 0 20rpx;
            .l-box{
                box-sizing: border-box;
                border-bottom: solid 1px #EDEDED;
                padding: 40rpx 0;
                .b-num{
                    display: flex;
                    justify-content: space-between;
                    // line-height: 80rpx;
                    .n-title{
                        font-size: 26rpx;
                        color: #333333;

                    }
                    .n-money{
                        font-size: 26rpx;
                        color: #333333;
                        text-align: right;

                    }
                }
                .b-time{
                    padding-top: 20rpx;
                    display: flex;
                    justify-content: space-between;
                    // line-height: 80rpx;
                    .t-title{
                        font-size: 24rpx;
                        color: gray;
                    }
                    .t-status{
                        font-size: 24rpx;
                        color:#999999;
                    }
                }
            }
        }
    }
    .business_number{
        display: flex;
        flex-direction: row;
        width: 226rpx;
        /*border: solid 0.5px #999999;*/
        border-radius: 10px;
        font-size: 25rpx;
        margin-right: -9px;
    }
    .search_image{
        margin-top: 7rpx;
        height: 35rpx;
        width: 35rpx;
    }
    .date_image{
        /*margin-left: 12rpx;*/
        height: 40rpx;
        width: 40rpx;
    }
    .date_image_2{
        /*margin-left: 12rpx;*/
        height: 17rpx;
        width: 30rpx;
        transform:  translate(0,20%);
        /*margin-left: 10rpx;*/
    }
    .empty_img{
        margin-top: 200rpx;
        width: 520rpx;
        height: 360rpx;
    }
    .empty_text{
        color: #333333;
        font-size: 26rpx;
        margin-top: 20rpx;
    }
    .empty_box{
        text-align: center;
    }
    .button_1{
        width: 108rpx;
        border: none;
        background-color: #FF9502;
        font-size:26rpx;
        color: #ffffff;
    }
    .button_1:nth-child(1){
        margin-right: 10rpx;
    }
    .total_cash{
        font-size: 26rpx;
        color: #F19317;
    }
    .top_1_box{
        display: flex;
        flex-direction: row;
        margin-left: 40%;
    }
    .watch_all{
        margin-left: 20rpx;
        font-size: 25rpx;
        color: #333333;
        margin-top: 9rpx;
    }
    .n-money-text{
        margin-top: 20rpx;
        color:forestgreen;
    }
    .select_box{
        position: fixed;
        bottom: 0;
    }
    .detail_button{
        position: fixed;
        bottom: 0;
        /*margin-bottom: 40rpx;*/
        width: 100%;
        background-color: #ffffff;
    }
    .detail{
        border: none;
        border-radius: 5px;
        color: #ffffff;
        width: 170rpx;
        height:70rpx;
        font-size: 26rpx;
        background-color: #FF9502;
        margin-top: 30rpx;
        margin-bottom: 30rpx;
    }
    .get_cash_money{
        margin-top: 15rpx;
        text-align: center;
        color: red;
        font-size: 32rpx;
    }

</style>
